﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Elite
{
    class Planet : Entity
    {
        /// <summary>
        /// in AU
        /// </summary>
        public double DistanceFromStar { get; set; }

        /// <summary>
        /// size. Earth = 1
        /// </summary>
        public double RelativeToEarthSize { get; set; }

        /// <summary>
        /// weight. Earth = 1
        /// </summary>
        public double RelativeToEarthWeight { get; set; }

        public Atmosphere Atmosphere { get; set; }

        public Planet()
        {
            this.Atmosphere = new Atmosphere();
        }

        public string Serialize()
        {
            return "TODO";
        }
    }

    class Atmosphere
    {
        public double CO2Ratio { get; set; }
        public double O2Ratio { get; set; }
        public double NRatio { get; set; }
        public double CH4Ratio { get; set; }

        public void SetRatios(Random rndTable, double[] values)
        {
            int co2Index = rndTable.Next(0, 4);
            int o2Index = co2Index;
            int nIndex = co2Index;
            int ch4Index = co2Index;

            do
            {
                o2Index = rndTable.Next(0, 4);
            } while (o2Index == co2Index);

            do
            {
                nIndex = rndTable.Next(0, 4);
            } while (nIndex == o2Index || nIndex == co2Index);

            do
            {
                ch4Index = rndTable.Next(0, 4);
            } while (ch4Index == nIndex || ch4Index == co2Index || nIndex == o2Index);

            this.CO2Ratio = values[co2Index];
            this.O2Ratio = values[o2Index];
            this.NRatio = values[nIndex];
            this.CH4Ratio = values[ch4Index];
        }
    }
}
